package general.appClass;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ModeApp extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7778758771621135830L;
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 * Set DB-Mode between "sql" and "db4o" in session
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String mode=request.getParameter("mode");
		if (mode==null){
			mode="sql";
		}
		
		request.getSession().setAttribute("mode", mode);
		
		//System.out.println("Referer:"+request.getHeader("Referer"));
		response.sendRedirect("index.jsp");
	}

}
